package leetcode;

import java.util.Arrays;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-01-02 10:47
 **/
public class LeetCode2126 {

    public boolean asteroidsDestroyed(int mass, int[] asteroids) {
        Arrays.sort(asteroids);
        //避免整型溢出
        long temp = mass;
        for (int asteroid : asteroids) {
            if (temp < asteroid) {
                return false;
            }

            temp += asteroid;
        }

        return true;
    }

}
